package com.pray;

import java.util.Objects;
import java.util.Scanner;
import java.util.Stack;

/**
 * Main
 *
 * @author 春江花朝秋月夜
 * @since 2023/11/18 15:31
 */
public class Main {
    private static Stack<Character> stack=new Stack<>();
    //括号匹配
    private static final Scanner sc=new Scanner(System.in);

    public static void main(String[] args) {
         boolean flag = true;
         while (true){
                String inputString = sc.nextLine();
                char[] input = inputString.toCharArray();
                while (input[0]!='#'&&flag){
                    switch (input[0]){
                        case '(':
                        case '{':
                            stack.push(input[0]);
                            break;
                        case ')':
                            if (!stack.isEmpty()&&stack.peek()=='('){
                                System.out.println(stack.pop());
                            }else {
                                flag =false;
                                break;
                            }
                        case '}':
                            if (!stack.isEmpty()&&stack.peek()=='{'){
                                System.out.println(stack.pop());
                            }else {
                                flag =false;
                                break;
                            }
                            break;
                        default:
                            throw new IllegalStateException("Unexpected value: " + input[0]);
                    }
                    inputString=sc.nextLine();
                    input=inputString.toCharArray();
                    System.out.println(stack);
                }
                break;
            }
    }
}
